package com.shynin.oauth.entity;

import com.shynin.common.bean.dto.UserDTO;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;

/**
 * Created by Shynin on 2019/1/31.
 */
public class UserDetailsImpl implements UserDetails {

    private UserDTO userDTO;

    public UserDetailsImpl(UserDTO userDTO) {
        this.userDTO = userDTO;
    }

    public UserDetailsImpl(){

    }

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        //todo 获取用户的权限
        return null;
    }

    @Override
    public String getPassword() {
        return userDTO.getPassword();
    }

    @Override
    public String getUsername() {
        return userDTO.getUserName();
    }

    @Override
    public boolean isAccountNonExpired() {
        // 账户是否没有过期
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        // 账户是否没有锁定
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        // 凭证是否没有过期
        return true;
    }

    @Override
    public boolean isEnabled() {
        // 账户是否启用
        return true;
    }
}
